Add can_resolve function to prevent panic#1127
Conversation
jkmassel
left a comment
There was a problem hiding this comment.
I wonder if we're solving this at the wrong layer? Should WpAuthenticationProvider have fetch_authentication_state so that the macro can allow each type of authentication to do the right thing? So then for Application Passwords we call ApplicationPasswordsRequestBuilder.retrieve_current_with_edit_context but for OAuth tokens we can inject some other implementation?
Sorry, I was wrong about this in the PR description. At the moment, the refresh application password logic does not run in WpComApiClient. So it's not actually relevant to the crash fixed in this PR. The the main purpose of I feel like it might be more appropriate to move #[uniffi::export(with_foreign)]
pub trait HostingProvider: Send + Sync {
fn resolve(&self, namespace: String, endpoint_segments: Vec<String>) -> Arc<ParsedUrl>;
fn authentication_state(&self, request_executor: Arc<dyn RequestExecutor>, auth: Arc<WpAuthenticationProvider>) -> Result<AuthenticationState, WpApiError>;
} |
I noticed a crash when testing #1126. The refresh application password logic that's built into the request builder macros is also running in
WpComApiClient, which should not happen.I have added an integration test to reproduce the crash. The crash happens when the following criteria are met:
WpComApiClientis used to request a WP.com endpoint.get_support_conversation_listis one example.